﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
/// <summary>
/// 关于toggle组，垂直水平组，scrollVIew组的UI——Editor
/// </summary>
public class GameSetting_Group : EditorWindow {

    bool logSettingGroup=false;
    bool isOpenLog = false;
    string myStr = "Hello World";
    float myFloat = 0.8f;

    Vector2 scrollPos;
    string t = "This is a string inside a Scroll view!";


    [MenuItem("Window/My Game/EditorWindow_Group")]
    public static void ShowGameSettingWindow()
    {
        EditorWindow.GetWindow(typeof(GameSetting_Group));
    }

    private void OnGUI()
    {
        GUILayout.Label("Game Setting", EditorStyles.boldLabel);
        myStr = EditorGUILayout.TextField("MyString", myStr);

        #region        /*---Toggle显示组---*/
        logSettingGroup = EditorGUILayout.BeginToggleGroup("LogSetting", logSettingGroup);
        isOpenLog = EditorGUILayout.Toggle("openLog", isOpenLog);
        isOpenLog = EditorGUILayout.ToggleLeft("openLog", isOpenLog);

        EditorGUILayout.EndToggleGroup();
        /*---Toggle显示组_end---*/
        #endregion

        #region        /*----水平，垂直组------*/
        Rect r = EditorGUILayout.BeginHorizontal("Button");//内部每个UI组件将会按照水平摆放呈现
        if (GUI.Button(r, GUIContent.none))
            Debug.Log("Go here");
        GUILayout.Label("I'm inside the button");
        GUILayout.Label("So am I");
            #region     /*嵌套垂直组（外部水平框组也会自适应垂直拉伸）*/
            Rect r1 = EditorGUILayout.BeginVertical("Button");
            //if (GUI.Button(r1, GUIContent.none))
            //    Debug.Log("Go here");
            GUILayout.Label("I'm inside the button");
            GUILayout.Label("So am I");
            GUILayout.Label("So am I2");
            EditorGUILayout.EndVertical();
            #endregion
        EditorGUILayout.EndHorizontal();
        #endregion

        #region scrollView组
        EditorGUILayout.BeginHorizontal();//建立水平组，里面的UI元素都会按照水平排列
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(100), GUILayout.Height(100));
            GUILayout.Label(t);
            EditorGUILayout.EndScrollView();
            if (GUILayout.Button("Add More Text", GUILayout.Width(100), GUILayout.Height(100)))
                t += " \nAnd this is more text!";

        EditorGUILayout.EndHorizontal();
        //if (GUILayout.Button("Clear"))
        //    t = "";
        #endregion

    }
}
